/*
 * 站点配置信息
 * @Description: jishupu-admin-template
 * @Author: 技术铺<jishupu@qq.com>
 * @Date: 2021-11-30
 *
 */
import { getSiteConfig } from '@/api/config'

const state = {}

const mutations = {
  SET_CONFIG: (state, items) => {
    state.name = items.name ?? ''
    state.domain = items.domain ?? ''
  }
}

const actions = {
  addSiteConfig({ commit }) {
    return new Promise((resolve, reject) => {
      getSiteConfig().then(response => {
        const data = response.data
        commit('SET_CONFIG', data)
        resolve(data)
      }).catch(error => {
        reject(error)
      })
    })
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
